﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace FlatOut.Dal.Domain
{
    [Table("Circuit", Schema = "dbo")]
    public class Circuit
    {
        /// <summary>
        /// 
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [Required]
        public string Name { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public virtual Group Group { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public List<Score> Scores { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [NotMapped]
        public IEnumerable<Score> ScoresLap
        {
            get { return Scores.Where(o => o.TypeScore == TypeScore.Lap);  }
        }

        /// <summary>
        /// 
        /// </summary>
        [NotMapped]
        public IEnumerable<Score> ScoresCircuit
        {
            get { return Scores.Where(o => o.TypeScore == TypeScore.Circuit); }
        }

        // Public constructor
        public Circuit()
        {
            this.Scores = new List<Score>();
        }
    }
}